package com.itheima.set;

import com.itheima.domain.Student;

import java.util.TreeSet;

/*
TreeSet的特点
存取无序
但是 数据有序
 */
public class Demo02 {

    public static void main(String[] args) {
        TreeSet<Integer> set = new TreeSet<>();
        set.add(5);
        set.add(4);
        set.add(1);
        set.add(3);
        set.add(1);
        set.add(2);
        System.out.println(set);

        TreeSet<String> set2 = new TreeSet<>();
        set2.add("abc");
        set2.add("def");
        set2.add("mnj");
        set2.add("ghj");
        set2.add("xyz");
        System.out.println(set2);

        TreeSet<Student> treeSet = new TreeSet<>();
        Student wu = new Student("wuyifan", 31);
        Student huang = new Student("huangzitao", 31);
        Student lu = new Student("luhan", 30);
        Student zhang = new Student("zhangyixing", 31);
        treeSet.add(wu);
        treeSet.add(huang);
        treeSet.add(lu);
        treeSet.add(zhang);
        System.out.println(treeSet);


    }
}
